package com.ruoyi.web.controller.wuyi;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wuyi.domain.WyPigDisease;
import com.ruoyi.wuyi.service.IWyPigDiseaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 猪病病症Controller
 * 
 * @author ruoyi
 * @date 2022-07-20
 */
@RestController
@RequestMapping("/wuyi/disease")
public class WyPigDiseaseController extends BaseController
{
    @Autowired
    private IWyPigDiseaseService wyPigDiseaseService;

    /**
     * 查询猪病病症列表
     */
    @PreAuthorize("@ss.hasPermi('wuyi:disease:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyPigDisease wyPigDisease)
    {
        startPage();
        List<WyPigDisease> list = wyPigDiseaseService.selectWyPigDiseaseList(wyPigDisease);
        return getDataTable(list);
    }

    /**
     * 导出猪病病症列表
     */
    @PreAuthorize("@ss.hasPermi('wuyi:disease:export')")
    @Log(title = "猪病病症", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyPigDisease wyPigDisease)
    {
        List<WyPigDisease> list = wyPigDiseaseService.selectWyPigDiseaseList(wyPigDisease);
        ExcelUtil<WyPigDisease> util = new ExcelUtil<WyPigDisease>(WyPigDisease.class);
        util.exportExcel(response, list, "猪病病症数据");
    }

    /**
     * 获取猪病病症详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuyi:disease:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(wyPigDiseaseService.selectWyPigDiseaseById(id));
    }

    /**
     * 新增猪病病症
     */
    @PreAuthorize("@ss.hasPermi('wuyi:disease:add')")
    @Log(title = "猪病病症", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyPigDisease wyPigDisease)
    {
        return toAjax(wyPigDiseaseService.insertWyPigDisease(wyPigDisease));
    }

    /**
     * 修改猪病病症
     */
    @PreAuthorize("@ss.hasPermi('wuyi:disease:edit')")
    @Log(title = "猪病病症", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyPigDisease wyPigDisease)
    {
        return toAjax(wyPigDiseaseService.updateWyPigDisease(wyPigDisease));
    }

    /**
     * 删除猪病病症
     */
    @PreAuthorize("@ss.hasPermi('wuyi:disease:remove')")
    @Log(title = "猪病病症", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wyPigDiseaseService.deleteWyPigDiseaseByIds(ids));
    }
}
